<?php 
include(dirname(__FILE__).'/../../../includes.php5');

include_once($project_path.'/class/user/user.class.php5');
session_start();
include_once($project_path.'/class/fw/dictionary.class.php5');

userUser::checkSession();

include_once($project_path.'/class/fw/login/loginWll.class.php5');
$action=(isset($_REQUEST['action'])?$_REQUEST['action']:'');
switch($action)
{
	case 'logout':
		userUser::logout();
?>
<script>
try
{
	if(opener)
	{
		opener.userConnectionRefreshLogin()
	}
	else
	{
		top.location.href="../../index.php5"
	}
}
catch(e)
{
}
self.close()
</script>
<?php
break;
	case "clearcookie":
		userUser::logout();

		ob_start();

		list($type, $response) = fwLoginWll::getClearCookieResponse();
		header("Content-Type: $type");
		print($response);

		ob_end_flush();
		break;
	default:
		list($responseOk, $userId, $usePersistentCookie) = fwLoginWll::processLogin($_REQUEST);
		if ($responseOk)
		{
			userUser::login('wll', $userId, $usePersistentCookie);
?>
<script>
try
{
	if(opener)
	{
		opener.login_popup.hide();
		opener.userConnectionRefreshLogin()
	}
	else
	{
		top.location.href="../../index.php5"
	}
}
catch(e)
{
}
self.close()
</script>
<?php
		}
		else
		{
?>
<script>
try
{
	if(opener)
	{
		opener.loginError("«USER_LOGIN_WLL_ERROR»", '<?php echo fwConverter::text2JSString($userId)?>', true);
	}
	else
	{
		top.location.href="../../index.php5"
	}
}
catch(e)
{
}
self.close()
</script>
<?php
		}
}
?>